@extends('layouts.template')

@section('title', '管理后台')

@section('content')

    <script>
        var selectedMenu = 'order/all';
        var selectedTitle = '订单详情';

        $(function(){

            var form = new Vue({
                el:'#contentpanel',
                data:{
                },
                computed:{
                },
                mounted:function(){
                },
                watch: {
                },
                methods:{
                },
                components:{
                }
            });

            var validator = $("#form").validate({
                rules: {
                    complain_id:{
                        required:true,
                    },
                    oc_handle_result:{
                        required:true,
                    },
                    oc_handle_explain:{
                        required:true,
                    },
                    oc_punish_amount:{
                        required:function(){
                            return $('[name=oc_handle_result]:checked').val() == '{{$result_agree}}';
                        },
                        number:true,
                        min:1,
                    },
                },
                messages: {
                    complain_id:{
                        required:'缺少投诉id',
                    },
                    oc_handle_result:{
                        required:'请选择处理操作',
                    },
                    oc_handle_explain:{
                        required:'请填写处理说明',
                    },
                    oc_punish_amount:{
                        required:'请填写处罚金额'
                    },
                },
                submitHandler: function(form) {
                    if (!confirm('请再次确认投诉处理操作')){
                        return false;
                    }

                    form.submit();
                },
            });

            window.showImage = function(source)
            {
                $("#image").find(".modal-content").html("<image src='"+source+"' width='100%' />");
                $("#image").modal('show');
            }

            $("#image").on("hidden.bs.modal", function() {
                $(this).removeData("bs.modal");
                $(this).find('.modal-content').empty();
            });

        });

    </script>

    <div class="contentpanel" id="contentpanel">

        <div class="row">
            <div class="col-md-12">

                @component('order.layouts.showHeader',['option'=>'complain','order'=>$order])
                @endcomponent

                <!-- Tab panes -->
                <div class="tab-content mb30">
                    <div class="tab-pane active">

                        <div class="panel panel-default">
                            <div class="panel-body nopadding">
                                <form class="form-bordered">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label"><strong><u>处理状态</u></strong></label>
                                        <div class="col-sm-9">
                                            {{$order->complain->status_text}}
                                        </div>
                                    </div><!-- form-group -->
                                </form>
                            </div><!-- panel-body -->
                            <div class="panel-heading">
                                <div class="panel-btns" style="display: none;">
                                    <a href="" class="panel-minimize tooltips" data-toggle="tooltip" title="" data-original-title="Minimize Panel"><i class="fa fa-minus"></i></a>
                                    <a href="" class="panel-close tooltips" data-toggle="tooltip" title="" data-original-title="Close Panel"><i class="fa fa-times"></i></a>
                                </div><!-- panel-btns -->
                                <h5 class="panel-title">订单编号：{{$order->order_number}}&nbsp;&nbsp;&nbsp;&nbsp;订单金额：{{$order->merchant_price}}元&nbsp;&nbsp;&nbsp;&nbsp;师傅名字：{{$order->master->real_name}}({{$order->master->phone}})</h5>
                            </div><!-- panel-heading -->
                            <div class="panel-body nopadding">
                                <form class="form-bordered" id="form" method="post" action="">
                                    {{csrf_field()}}
                                    <input type="hidden" name="complain_id" value="{{$order->complain->oc_id}}">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label"><strong><u>投诉信息</u></strong></label>
                                        <div class="col-sm-9">
                                            投诉编号：{{$order->complain->oc_number}}
                                        </div>
                                        <div class="col-sm-9">
                                            发起时间：{{$order->complain->oc_add_time}}
                                        </div>
                                        <div class="col-sm-9">
                                            投诉类别：{{$order->complain->category_text}} - {{$order->complain->subcategory_text}}
                                        </div>
                                        <div class="col-sm-9">
                                            投诉内容：{{$order->complain->oc_content}}
                                        </div>
                                        <div class="col-sm-9">
                                            @foreach ($order->complain->complain_imgs_url as $img)
                                                <a onclick="showImage('{{$img}}')" href="javascript:void(0)"><img width="150" src="{{$img}}"></a>
                                            @endforeach
                                        </div>
                                    </div><!-- form-group -->

                                    @if ($order->complain->complaining)
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label"><strong><u>投诉处理</u></strong></label>
                                            <div class="col-sm-9">
                                                <div class="radio"><label><input type="radio" name="oc_handle_result" value="{{$result_agree}}"> 投诉成立</label>
                                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;处罚金额<input type="text" name="oc_punish_amount">元</div>
                                            </div>
                                            <div class="col-sm-9">
                                                <div class="radio"><label><input type="radio" name="oc_handle_result" value="{{$result_disagree}}"> 投诉失败</label></div>
                                            </div>
                                            <div class="col-sm-9">
                                                处理说明：
                                            </div>
                                            <div class="col-sm-9">
                                                <textarea class="form-control" rows="5" name="oc_handle_explain"></textarea>
                                            </div>
                                        </div><!-- form-group -->

                                        <div class="panel-footer">
                                            <div class="row">
                                                <div class="col-sm-9 col-sm-offset-0">
                                                    <button class="btn btn-primary mr5" type="submit">确认</button>
                                                </div>
                                            </div>
                                        </div><!-- panel-footer -->

                                    @else
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label"><strong><u>客服处理结果</u></strong></label>
                                            <div class="col-sm-9">
                                                处理结果：{{$order->complain->result_text}}
                                            </div>
                                            <div class="col-sm-9">
                                                处理时间：{{$order->complain->oc_handle_time}}
                                            </div>
                                            <div class="col-sm-9">
                                                处罚金额：{{$order->complain->oc_punish_amount}}元
                                            </div>
                                            <div class="col-sm-9">
                                                处理说明：{{$order->complain->oc_handle_explain}}
                                            </div>
                                        </div><!-- form-group -->
                                    @endif

                                </form>
                            </div><!-- panel-body -->
                        </div>

                    </div><!-- tab-pane -->

                    </div><!-- tab-pane -->
                </div><!-- tab-content -->

            </div><!-- col-md-6 -->
        </div>
    </div><!-- contentpanel -->

    <div class="modal fade" id="image" tabindex="-1" role="dialog" data-keyboard="false">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
            </div>
        </div>
    </div>

@endsection

